#ifndef NET_TCP_CLIENT_H
#define NET_TCP_CLIENT_H

#include "TcpSession.h"

namespace mp_net
{
	class TcpClient : public TcpSession
	{
	public:
		TcpClient():TcpSession(1){m_resolver = NULL;
			m_connected = false;}
		virtual ~TcpClient(){
			StopThread(); delete m_resolver;}

		void ThreadInitialization();
		void ThreadUpdate();
		void ThreadShutdown();

		void SetIoService(spIoService ioService);

		void AsyncResolve();
		void AsyncResolveProc(
			const boost::system::error_code& error,
			tcp::resolver::iterator endpoint_iterator);

		void AsyncConnect();
		void AsyncResolveProc(
		const boost::system::error_code& error);

	private:
		void UpdateResolver();

		tcp::resolver*	m_resolver;
		volatile bool	m_connected;
	};
}

#endif